package com.osdp.sc.api.impl;

import com.osdp.sc.api.IPermissionApi;
import com.osdp.sc.dto.PermissionDTO;
import com.osdp.uc.feign.UcFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;
import java.util.Set;

@Service
public class PermissionApiFeignImpl implements IPermissionApi {

    @Autowired
    private UcFeignService ucFeignService;

    @Override
    public List<PermissionDTO> queryPermissionsByUserId(String userId) {
        return ucFeignService.queryPermissionsByUserId(userId);
    }

    @Override
    public List<PermissionDTO> queryPermissionButtonByUserId(String userId) {
        return ucFeignService.queryPermissionButtonByUserId(userId);
    }

    @Override
    public List<PermissionDTO> queryPermissionAPIByUserId(String userId) {
        return ucFeignService.queryPermissionAPIByUserId(userId);
    }

    @Override
    public List<String> queryPermsCodeByUserId(String userId) {
        return ucFeignService.queryPermsCodeByUserId(userId);
    }

    @Override
    public Optional<List<PermissionDTO>> queryPermsButtonAndAPIByRoleCode(Set<String> roleCodes, String tenantId) {
        return ucFeignService.queryPermsButtonAndAPIByRoleCode(roleCodes,tenantId);
    }

    @Override
    public boolean allow(String uri, String method, Set<String> authoritys) {
        return ucFeignService.allow(uri, method, authoritys);
    }
}
